<template>
	<view>
		<view class="Info" v-if="myInfo">
			<view class="User">
				<view class="userBox">
					<image
						:src="$imgUrls(myInfo.headimg)"
						mode="aspectFill"
						class="userImg"></image>
					<view class="Lvs">{{ myInfo.upLevelInfo.thisLevelTitle }}</view>
				</view>
				<view class="infoText">
					<text class="size30">{{ myInfo.name }}</text>
					<text class="size30 m-top10">{{ myInfo.tel }}</text>
				</view>
			</view>
		</view>

		<view class="LvBox" v-if="myInfo">
			<text class="LvTitle">管理等级</text>
			<view class="LvWrapper">
				<text class="lv_name">{{ myInfo.upLevelInfo.thisLevelTitle }}</text>
				<view class="content">
					<text class="Txt">{{ myInfo.upLevelInfo.text }}</text>
					<view class="line">
						<u-line-progress
							:percentage="myInfo.upLevelInfo.proportion"
							height="9"
							activeColor="#ffcc00"></u-line-progress>
					</view>
				</view>
				<text class="currentLv">{{ myInfo.upLevelInfo.nextLevelTitle }}</text>
			</view>
		</view>

		<view class="Team">
			<view class="titleBox">
				<text class="black size30 bold500">团队成员</text>
				<view class="select" @click="show = true">
					<text class="black size28">{{ Itemname }}</text>
					<view class="iconfont icon-xiasanjiaoxing black size28 p-left10"></view>
				</view>
			</view>

			<view
				class="list"
				v-for="(item, index) in pageData"
				:key="index"
				v-if="pageData.length">
				<view class="Infos">
					<view class="userBox">
						<image
							:src="$imgUrls(item.headimg)"
							mode="aspectFill"
							class="userImg"></image>
						<view class="Lvs" v-if="item.thisTeamLevel">{{
							item.thisTeamLevel.name
						}}</view>
					</view>
					<view class="d-flex f-column">
						<text class="ellipsis black size26">{{ item.name }}</text>
						<text class="color_33 h6 m-top6">{{ item.tel }}</text>
						<text class="color_33 h6 m-top6">{{ item.add_date }}</text>
					</view>
				</view>
				<view class="d-flex f-column j-sb">
					<text class="perfTxt">自购:{{ item.teamInfo.my_order_money }}</text>
					<text class="perfTxt">团队:{{ item.teamInfo.team_user_num }}人</text>
					<text class="perfTxt">业绩:{{ item.teamInfo.team_order_money }}</text>
				</view>
			</view>
			<view class="p-top100 p-bot100" v-if="!pageData.length">
				<u-empty mode="list" text="暂无相关内容"></u-empty>
			</view>
		</view>

		<u-picker
			:show="show"
			:columns="columns"
			keyName="name"
			@cancel="show = false"
			@confirm="confirm"></u-picker>
	</view>
</template>

<script>
	import Api from '@/common/Api.js';
	export default {
		data() {
			return {
				img: 'https://msraimgcdn.mogoie.com/6137/1731484174751.jpg',
				show: false,
				columns: [],
				page: 1,
				limit: 10,
				id: '',
				Itemname: '全部',
				getMore: true,
				pageData: [],
				myInfo: '',
			};
		},
		onLoad() {
			this.getConfig();
			this.getLevelList();
		},
		methods: {
			async getConfig() {
				const result = await Api.getConfig();
				this.myInfo = result;
			},
			getLevelList() {
				this.$http
					.post({
						url: '/cqzmqmH5Api/getLevelList',
					})
					.then((res) => {
						if (res.errcode != '100') return this.$Toast(res.msg);
						const result = res.data || [];
						result.unshift({
							id: '',
							name: '全部',
						});
						this.columns = [[...result]];
						this.getTeamUserList();
					});
			},
			getTeamUserList() {
				this.$http
					.post({
						url: '/cqzmqmH5Api/getTeamUserList',
						data: {
							page: this.page,
							limit: this.limit,
							id: this.id,
						},
					})
					.then((res) => {
						if (res.errcode != 100) return this.$Toast(res.msg);
						const reuslt = res.data || [];
						this.page == 1
							? (this.pageData = reuslt)
							: (this.pageData = [...this.pageData, ...reuslt]);
						if (reuslt.length < this.limit) this.getMore = false;
					});
			},
			confirm(e) {
				this.id = e.value[0].id;
				this.Itemname = e.value[0].name;
				this.page = 1;
				this.getMore = true;
				this.show = false;
				this.getTeamUserList();
			},
		},
		onReachBottom() {
			if (!this.getMore) return;
			this.page++;
			this.getTeamUserList();
		},
	};
</script>
<style>
	page {
		background-color: #f2f2f2;
		padding-bottom: 24rpx;
	}
</style>
<style lang="scss" scoped>
	.Team {
		width: 690rpx;
		margin: 30rpx auto 0;
		background-color: #fff;
		border-radius: 10rpx;
		.titleBox {
			width: 100%;
			padding: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.select {
				display: flex;
				align-items: center;
			}
		}
		.list {
			width: 100%;
			padding: 20rpx;
			border-bottom: 1px solid #f2f2f2;
			display: flex;
			align-items: center;
			.Infos {
				flex: 1;
				display: flex;
			}
			.perfTxt {
				color: #333;
				font-size: 24rpx;
				margin-top: 6rpx;
			}
		}
	}
	.LvBox {
		width: 690rpx;
		padding: 20rpx;
		background-color: #fff;
		margin: 26rpx auto 0;
		border-radius: 10rpx;
		.LvTitle {
			color: #333;
			font-size: 30rpx;
		}
		.LvWrapper {
			width: 100%;
			display: flex;
			align-items: center;
			margin-top: 20rpx;
			.lv_name {
				color: #000;
				font-size: 28rpx;
				font-weight: 500;
			}
			.content {
				flex: 1;
				margin: 0 20rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				.Txt {
					color: #b7655a;
					font-size: 26rpx;
				}
				.line {
					width: 100%;
					margin-top: 10rpx;
				}
			}
			.currentLv {
				color: #333;
				font-size: 32rpx;
			}
		}
	}
	.Info {
		width: 100%;
		background-color: #000066;
		padding: 40rpx 24rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		.User {
			width: 100%;
			display: flex;
			align-items: center;

			.infoText {
				display: flex;
				flex-direction: column;
				color: #fff;
				font-size: 30rpx;
			}
		}
		.Datas {
			width: 100%;
			display: flex;
			justify-content: space-between;
			padding: 0 20rpx;
			margin-top: 26rpx;
			.tex {
				color: #fff;
				font-size: 28rpx;
			}
		}
	}
	.userBox {
		width: 150rpx;
		height: 120rpx;
		display: flex;
		justify-content: center;
		position: relative;
		.userImg {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
		}
		.Lvs {
			max-width: 100%;
			background-color: #ff9900;
			color: #fff;
			font-size: 22rpx;
			padding: 2rpx 10rpx;
			border-radius: 4rpx;
			position: absolute;
			bottom: 0;
			left: 50%;
			transform: translateX(-50%);
			text-align: center;
			white-space: nowrap;
		}
	}
</style>
